package com.fangzhi.mobel.vo;

import com.fangzhi.utils.GlobalParam;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
@Accessors(chain = true)
public class OrderDetailVo implements Serializable {

    private long customerId;
    private Integer id;
    private Integer btype =1;
    private String orderId;
    private Long adminAccountId;
    private String adminAccountName;
    private Double totalAmount;
    private Double depositAmount;
    private String wxId;
    private String customerComments;
    private Double afterAmount;
    private Double discountAmount;
    private Integer status;
    // 是否可以审核 0:不可审核 1：可审核
    private Integer adminStatus = 0;
//    private String logisticName;
//    private String logisticId;
    private String ctime;
    private String hotelName;
    private String name;
    private String mobile;
    private String address;
    private List<Products> productList;
    private List<Payments> paymentsList;
    private List<Afters> aftersList;
    private List<LogsVo> logsVos;
    private String imageComments = "";
    private Double logisticsPrice;
    private Integer priceType;
    private Integer materialType;
    private Integer customerType;
    private Integer freeShippingType;
    private List<QueryOrderLogisticsDetailVo.Detail> detailList;
    private String comments;

    public void setImageComments(List<String> imageComments) {
        StringBuilder sb = new StringBuilder();
        imageComments.stream().forEach(T->{
            sb.append(GlobalParam.IMAGE_URL + T).append(",");
        });
        if (StringUtils.hasText(sb))
            this.imageComments = sb.toString().substring(0, sb.length() - 1);
    }

    @Data
    @Accessors(chain = true)
    public static class Products{
        private long productTypeId;
        private String productName1;
//        private String productName2;
        private String productName3;
        private String productName4;
        private List<Long> technologyId = new ArrayList<>();
        private List<Technoloyg> technologyList = new ArrayList<>();
        // 总价
        private Double totalAmount;
        // 单价
        private Double price;
        private Integer num;
        private String comments;
        private Long badTypeId;
        private String badTypeName;
        private Double premiumPrice = 0D;
        private double priceCopy;
        private double priceCopy2;
        @Data
        public static class Technoloyg{
            private Long id;
            private String technologyName;
        }
    }

    @Data
    public static class Payments{
        private Integer id;
        private Integer type;
        private String imageCover;
        private Integer btype = 2;
        private Integer status;
        private Double price;
        private String comments;
        // 是否可以审核 0:不可审核 1：可审核
        private Integer adminStatus = 0;
        private List<LogsVo> logsVos;
        private String ctime;
        public void setImageCover(String imageCover) {
            String[] split = imageCover.split(",");
            StringBuffer sb = new StringBuffer();
            for (String s : split) {
                sb.append(GlobalParam.IMAGE_URL + s).append(",");
            }
            if (StringUtils.hasText(sb))
                this.imageCover = sb.toString().substring(0, sb.length() - 1);
//            if(StringUtils.hasText(imageCover))
//                this.imageCover = GlobalParam.IMAGE_URL + imageCover;
        }
    }
    @Data
    public static class Afters{
        private Integer id;
        private Integer type =3;
        private List<LogsVo> logsVos;
        private Integer status;
        private String imageCover;
        private Double price;
        private Double afterPrice;
        private String belongTo;
        private String action;
        private String comments;
        private String returnOrderNumber;
        // 是否可以审核 0:不可审核 1：可审核
        private Integer adminStatus = 0;
        private String ctime;
        public void setImageCover(String imageCover) {
            if(StringUtils.hasText(imageCover))
                this.imageCover = GlobalParam.IMAGE_URL + imageCover;
        }
    }
}
